<?php
class stFacebookCouponTemplate_model extends stmodel_2_1{

    public function __construct($config) {
        parent::__construct ( $config );
        $this->setTableName('st_coupon_templates');
        $this->setPrimaryKey('CouponTemplateID');
    }
    public function getgraphic($id){
        $image = $this->get_var("SELECT TemplatesGraphicsPath FROM st_coupon_template_graphics WHERE CouponTemplateGraphicsID=".$id);
        return 'https://s3-ap-southeast-1.amazonaws.com/'.$this->config['gallery_bucket'].'/fb-app-coupon/'.substr($image,0,strlen($image)-4).'-thumb'.substr($image,-4,4);
    }
    public function getFull($id){
        return 'https://s3-ap-southeast-1.amazonaws.com/'.$this->config['gallery_bucket'].'/fb-app-coupon/'.$this->get_var("SELECT TemplatesGraphicsPath FROM st_coupon_template_graphics WHERE CouponTemplateGraphicsID=".$id);
    }
    public function getdiscount($id){
        return $this->get_var("SELECT DiscountTypeName FROM st_discount_types WHERE DiscountTypeID=".$id);
    }

    


}